import axios from "./axios";

class Env {
    constructor(){}

    // 新建任务
    createTask(taskName:any, groupId:any, tagIDs:Array<string>, mark:string){
        return axios.post('/api/rpatask/createTask', {
            taskName: taskName,
            groupId: groupId,
            tagIDs: tagIDs,
            taskData: "",
            mark: mark,
            costPoint: 0
        });
    }

    // 分页获取任务列表
    fetchTasks(taskName:any, groupId:any, tagIds:any, page:any, pageSize:any) {
        return axios.post('/api/rpatask/fetchTasks', {taskName, groupId, tagIds, page, pageSize});
    }

    // 根据ID获取任务数据
    fetchTaskById(id:any){
        return axios.post('/api/rpatask/fetchTaskById', {id});
    }

    // 删除任务
    delTask(id:any) {
        return axios.post('/api/rpatask/deleteTask', {id});
    }

    //更新任务信息
    updateTask(id:any, taskName:any, groupId:any, tagIDs:Array<string>, mark:string){
        return axios.post('/api/rpatask/updateTask', {
            id: id,
            taskName: taskName,
            groupId: groupId,
            tagIDs: tagIDs,
            mark: mark
        });
    }

    // 更新任务Flow数据
    updateTaskData(id:any, taskData:any, costPoint:any){
        return axios.post('/api/rpatask/updateTaskFlowData', {
            id: id,
            taskData: taskData,
            costPoint: costPoint
        });
    }

    // 执行任务
    executeTask(id:any, costPoint:any){
        return axios.post('/api/rpatask/executeTask', {
            id: id,
            costPoint: costPoint
        });
    }
    
    // 创建RPA标签
    createRPATag(tagName:any, mOrder:any) {
        mOrder = parseInt(mOrder);
        return axios.post('/api/rpatag/create', {tagName, mOrder});
    }

    // RPA标签
    fetchRPATag(tagName:any, page:any, pageSize:any){
        return axios.post('/api/rpatag/fetch', {tagName, page, pageSize});
    }

    // 删除RPA标签
    delteRPATag(id:any){
        return axios.post('/api/rpatag/delete', {id});
    }

    // 更新RPA标签
    updateRPATag(id:any, tagName:any, mOrder:any) {
        mOrder = parseInt(mOrder);
        return axios.post('/api/rpatag/update', {id, tagName, mOrder});
    }

    // 创建RPA分组
    createRPAGroup(groupName:any, mOrder:any) {
        mOrder = parseInt(mOrder);
        return axios.post('/api/rpagroup/create', {groupName, mOrder});
    }

    // RPA分组
    fetchRPAGroup(groupName:any, page:any, pageSize:any){
        return axios.post('/api/rpagroup/fetch', {groupName, page, pageSize});
    }

    // 删除RPA分组
    delteRPAGroup(id:any){
        return axios.post('/api/rpagroup/delete', {id});
    }

    // 创建RPA分组
    updateRPAGroup(id:any, groupName:any, mOrder:any) {
        mOrder = parseInt(mOrder);
        return axios.post('/api/rpagroup/update', {id, groupName, mOrder});
    }

    // 获取点数日志
    fetchPoinsts(page:any, pageSize:any) {
        return axios.post('/api/rpatask/fetchPoints', { page, pageSize});
    }

    // 执行详情
    fetchDetail(page:any, pageSize:any) {
        return axios.post('/api/rpatask/fetchDetail', { page, pageSize});
    }

    // 执行日志
    createDetail(taskId:any, taskName:any, taskStatus:any, executeStart:any, executeEnd:any, executeLogID:any){
        return axios.post('/api/rpatask/createDetail', { 
            taskId,
            taskName,
            taskStatus,
            executeStart,
            executeEnd,
            executeLogID
        });
    }
}

export default new Env();